Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A couple of small bugfixes #194

Merged
merged 2 commits into from
Jun 3, 2024
Merged

A couple of small bugfixes #194

merged 2 commits into from
Jun 3, 2024

Conversation

jt-traub
Copy link
Contributor

@jt-traub jt-traub commented Jun 1, 2024

Enable JSON reports for NO v7
Fix a couple of places where the JSON->text report wasn't quite right. Fix a bug where the inactive turns handling was slightly wonky in the JSON report.

Enable JSON reports for NO v7
Fix a couple of places where the JSON->text report wasn't quite right.
Fix a bug where the inactive turns handling was slightly wonky in the
JSON report.
@@ -409,7 +409,7 @@ void Faction::build_json_report(json& j, Game *game, size_t **citems) {
j["administrative"]["show_unit_attitudes"] = (showunitattitudes != 0);

if(!password_unset) j["administrative"]["password"] = password->const_str();
if(Globals->MAX_INACTIVE_TURNS) {
if(Globals->MAX_INACTIVE_TURNS != -1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 is the signifier for ignore turn inactivity, and if(-1) evaluates to true, so this was a bug but unlikely to get caught since noone actually runs with -1 as the inactive turn setup.

@@ -524,9 +524,9 @@ void TextReportGenerator::output(ostream& f, const json& report, bool show_regio

bool show_unit_attitudes = false;
if (report.contains("administrative")) {
if (!report["administrative"].contains("times_sent"))
if (!report["administrative"].contains("times_sent") || !report["administrative"]["times_sent"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd initially made the assumption here that the field wouldn't be output at all if it was false, but the actual generation
code always created the field and set it's value to either true or false. For safety it will now check existence and/or the value being truthful.

In the case of times, if the value isn't set OR it's set to false then the times isn't being set. For the password, if it's set AND it's set to true then we output the warning.

Found this while testing the new website with an downloaded report for a new faction where it had a password set..
This wasn't caught in unit tests or snapshot tests as they don't set faction passwords so they (as expected) had this warning.

@jt-traub jt-traub marked this pull request as ready for review June 1, 2024 22:43
@jt-traub jt-traub requested review from valdisz and artyomtrityak June 1, 2024 22:43
@jt-traub jt-traub merged commit 11f1ab2 into master Jun 3, 2024
10 checks passed
@jt-traub jt-traub deleted the jt-tiny-bugfixes branch June 3, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants